<?php
/*
*Linx Wrapper for My-Linx.com API
*Developed by Daryl Cumbo
*Last Modified 09'th August 2008
*/
class LinxWrapper
{
	protected $wsdl ="http://www.my-linx.com/Labs/LinxWebServices.asmx?WSDL";
	
	function GetLatestContentForGuests($guid)
	{
		$client = new SoapClient($this->wsdl); 
		
		$params = array 
		(
			'AppId'=> $guid
		);
		
		try
		{
			$result = $client->GetLatestContentForGuests($params);
		} 
		catch (SoapFault $e) 
		{
			return "Error: {$e->faultstring}";
		}

		return $result->GetLatestContentForGuestsResult;
	}
	
	function GetLatestContent($guid, $username, $password)
	{
		$client = new SoapClient($this->wsdl); 
		
		$user = array(
			'UserName' => $username,
			'Password' => $password
		);
		
		$params = array(
			'AppId'=> $guid,
			'Login'=> $user
		);
		
		try
		{
			$result = $client->GetLatestContent($params);
		} 
		catch (SoapFault $e) 
		{
			return "Error: {$e->faultstring}";
		}

		return $result->GetLatestContentResult;
	}
	
	function GetFavorites($guid, $username, $password)
	{
		$client = new SoapClient($this->wsdl); 
		
		$user = array(
			'UserName' => $username,
			'Password' => $password
		);
		
		$params = array(
			'AppId'=> $guid,
			'Login'=> $user
		);
			
		try
		{
			$result = $client->GetFavorites($params);
		} 
		catch (SoapFault $e) 
		{
			return "Error: {$e->faultstring}";
		}

		return $result->GetFavoritesResult;
	}
	
	function GetMessages($guid, $username, $password)
	{
		$client = new SoapClient($this->wsdl); 
		
		$user = array(
			'UserName' => $username,
			'Password' => $password
		);
		
		$params = array(
			'AppId'=> $guid,
			'Login'=> $user
		);
		
		try
		{
			$result = $client->GetMessages($params);
		} 
		catch (SoapFault $e) 
		{
			return "Error: {$e->faultstring}";
		}

		return $result->GetMessagesResult;
	}

	function GetMessage($guid, $username, $password, $msgID)
	{
		$client = new SoapClient($this->wsdl); 
		
		$user = array(
			'UserName' => $username,
			'Password' => $password
		);
		
		$params = array(
			'AppId'=> $guid,
			'Login'=> $user,
			'MessageId'=> $msgID
		);
		
		try
		{
			$result = $client->GetMessage($params);
		} 
		catch (SoapFault $e) 
		{
			return "Error: {$e->faultstring}";
		}

		return $result->GetMessageResult;
	}
	
	//ask ben
	function GetUnreadMessages($guid, $username, $password)
	{
		$client = new SoapClient($this->wsdl); 
		
		$user = array(
			'UserName' => $username,
			'Password' => $password
		);
		
		$params = array(
			'AppId'=> $guid,
			'Login'=> $user
		);
		
		try
		{
			$result = $client->GetUnreadMessages($params);
		} 
		catch (SoapFault $e) 
		{
			return "Error: {$e->faultstring}";
		}
		
		return $result->GetUnreadMessagesResult;
	}
	
	function DeleteMessage($guid, $username, $password, $msgID)
	{
		$client = new SoapClient($this->wsdl); 
		
		$user = array(
			'UserName' => $username,
			'Password' => $password
		);
		
		$params = array(
			'AppId'=> $guid,
			'Login'=> $user,
			'MessageId'=> $msgID
		);
		
		try
		{
			$result = $client->DeleteMessage($params);
		} 
		catch (SoapFault $e) 
		{
			return "Error: {$e->faultstring}";
		}
		
		return $result->DeleteMessageResult;
	}
	//ask ben
	function SendMessage($guid, $username, $password, $msgID, $senderID, $subject, $msgText)
	{
		$client = new SoapClient($this->wsdl); 
		
		$user = array(
			'UserName' => $username,
			'Password' => $password
		);
		
		$params = array(
			'AppId'=> $guid,
			'Login'=> $user,
			'MessageId'=> $msgID,
			'SenderId'=> $senderID,
			'Subject'=> $subject,
			'MessageText'=> $msgText
		);
		
		try
		{
			$result = $client->SendMessage($params);
		} 
		catch (SoapFault $e) 
		{
			return "Error: {$e->faultstring}";
		}
		
		return $result->SendMessageResult;		
	}
	
	function GetContentBySearch($guid, $username, $password, $search)
	{
		$client = new SoapClient($this->wsdl); 
		
		$user = array(
			'UserName' => $username,
			'Password' => $password
		);
		
		$params = array(
			'AppId'=> $guid,
			'Login'=> $user,
			'Search'=> $search
		);
		
		try
		{
			$result = $client->GetContentBySearch($params);
		} 
		catch (SoapFault $e) 
		{
			return "Error: {$e->faultstring}";
		}
		
		return $result->GetContentBySearchResult;	
	}
	
	function GetContentBySearchForGuests($guid, $search)
	{
		$client = new SoapClient($this->wsdl); 
		
		$params = array(
			'AppId'=> $guid,
			'Search'=> $search
		);
		
		try
		{
			$result = $client->GetContentBySearchForGuests($params);
		} 
		catch (SoapFault $e) 
		{
			return "Error: {$e->faultstring}";
		}
		
		return $result->GetContentBySearchForGuestsResult;	
	}
}
?>


